<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p id="p01">{{msg}}</p>
        <p>{{str}}</p>
        <input type="button" value="销毁" @click="destroy">
    </div>
    <input id="btn01" type="button" value="修改msg" >
</body>
</html>
<script src="./js/vue.js"></script>
<script>

    let vm = new Vue({
        el:"#app",
        data:{
            msg:"hello",
            str:"hi",
            books:[]
        },  
        methods:{
            destroy(){
                this.$destroy();
            }
        },      
        beforeCreate:function(){
            console.log("====beforeCreate=====");
            console.log("this.msg",this.msg);//undefined;            
        },        
        created:function(){
            console.log("====created=====");
            console.log("this.msg",this.msg);//hello;
            // 此处可以发送请求。
            
        },
        beforeMount(){
            console.log("====beforeMount=====");
            console.log(document.getElementById("p01").innerHTML);
        },
        mounted(){
            console.log("====mounted=====");
            console.log(document.getElementById("p01").innerHTML);
        },
        beforeUpdate(){
            console.log("====beforeUpdate=====");
            console.log(document.getElementById("p01").innerHTML);
        },
        updated(){
            console.log("====updated=====");
            console.log(document.getElementById("p01").innerHTML);
        },
        beforeDestroy(){
            console.log("=====beforeDestroy====");
        },
        destroyed(){
            console.log("====destroyed====");
            console.log("this",this);
        }
    });

    document.getElementById("btn01").onclick = function(){
        vm.msg += "1";
        console.log("vm.msg",vm.msg);
    }
</script>